home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C & C++ Multimedia Cyber Classroom
/
C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso
/
cpphtp2
/
code.jar
/
code
/
ch11
/
fig11_19.txt
< prev
next >
Wrap
Text File
|
1998-02-27
|
1KB
|
32 lines
1 // Fig. 11.19: fig11_19.cpp
2 // Creating and testing user-defined, nonparameterized
3 // stream manipulators.
4 #include <iostream.h>
5
6 // bell manipulator (using escape sequence \\a)
7 ostream& bell( ostream& output ) { return output << '\\a'; }
8
9 // ret manipulator (using escape sequence \\r)
10 ostream& ret( ostream& output ) { return output << '\\r'; }
11
12 // tab manipulator (using escape sequence \ )
13 ostream& tab( ostream& output ) { return output << '\ '; }
14
15 // endLine manipulator (using escape sequence \n
16 // and the flush member function)
17 ostream& endLine( ostream& output )
18 {
19 return output << '\n' << flush;
20 }
21
22 int main()
23 {
24 cout << "Testing the tab manipulator:" << endLine
25 << 'a' << tab << 'b' << tab << 'c' << endLine
26 << "Testing the ret and bell manipulators:"
27 << endLine << "..........";
28 cout << bell;
29 cout << ret << "-----" << endLine;
30 return 0;
31 }